home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / DOC2HLP.C < prev    next >
C/C++ Source or Header  |  1992-03-25  |  2KB  |  79 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: doc2hlp.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
  3. #endif
  4.  
  5. /*
  6.  * doc2hlp.c  -- program to convert Gnuplot .DOC format to 
  7.  * VMS help (.HLP) format.
  8.  *
  9.  * This involves stripping all lines with a leading ?,
  10.  * @, #, or %.
  11.  * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
  12.  *
  13.  * usage:  doc2hlp < file.doc > file.hlp
  14.  *
  15.  * Original version by David Kotz used the following one line script!
  16.  * sed '/^[?@#%]/d' file.doc > file.hlp
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <ctype.h>
  21.  
  22. #define MAX_LINE_LEN    256
  23. #define TRUE 1
  24. #define FALSE 0
  25.  
  26. main()
  27. {
  28.     convert(stdin,stdout);
  29.     exit(0);
  30. }
  31.  
  32.  
  33. convert(a,b)
  34.     FILE *a,*b;
  35. {
  36.     static char line[MAX_LINE_LEN];
  37.  
  38.     while (fgets(line,MAX_LINE_LEN,a)) {
  39.        process_line(line, b);
  40.     }
  41. }
  42.  
  43. process_line(line, b)
  44.     char *line;
  45.     FILE *b;
  46. {
  47.     static int line_count = 0;
  48.  
  49.     line_count++;
  50.  
  51.     switch(line[0]) {        /* control character */
  52.        case '?': {            /* interactive help entry */
  53.           break;            /* ignore */
  54.        }
  55.        case '@': {            /* start/end table */
  56.           break;            /* ignore */
  57.        }
  58.        case '#': {            /* latex table entry */
  59.           break;            /* ignore */
  60.        }
  61.        case '%': {            /* troff table entry */
  62.           break;            /* ignore */
  63.        }
  64.        case '\n':            /* empty text line */
  65.        case ' ': {            /* normal text line */
  66.           (void) fputs(line,b); 
  67.           break;
  68.        }
  69.        default: {
  70.           if (isdigit(line[0])) { /* start of section */
  71.             (void) fputs(line,b); 
  72.           } else
  73.             fprintf(stderr, "unknown control code '%c' in column 1, line %d\n", 
  74.                   line[0], line_count);
  75.           break;
  76.        }
  77.     }
  78. }
  79.